<?php
/**
 * @Copyright Copyright (C) 2010-2012
 * @license GNU/GPL http://www.gnu.org/copyleft/gpl.html
 + Created by:          Webit Solution
 * Company:		Webit Solution
 + Contact:		www.webits.asia, developer@webits.asia
 * Created on:	Mar 21, 2012
 ^
 + Project: 		WRecruit
 * File Name:	views/employer/tmpl/formcompany.php
 ^ 
 * Description: template for form company
 ^ 
 * History:		NONE
 ^ 
 */

defined('_JEXEC') or die('Restricted access');

 global $mainframe;

$editor = & JFactory :: getEditor();
JHTML :: _('behavior.calendar');


 $document =& JFactory::getDocument();
 $document->addStyleSheet('components/com_wrecruit/css/'.$this->config['theme']);

?>
<?php if ($this->config['offline'] == '1'){ ?>
<table cellpadding="0" cellspacing="0" border="0" width="100%" >
	<tr><td valign="top" class="<?php echo $this->theme['title']; ?>" >	<?php echo $this->config['title']; ?></td></tr>
	<tr><td height="25"></td></tr>
	<tr><td class="wrecruitmsg">
		<?php echo $this->config['offline_text']; ?>
	</td></tr>
</table>
<?php }else{ ?>
<script language="javascript">
function myValidate(f) {
        if (document.formvalidator.isValid(f)) {
                f.check.value='<?php echo JUtility::getToken(); ?>';//send token
        }
        else {
                alert('Some values are not acceptable.  Please retry.');
				return false;
        }
		return true;
}

</script>

<table cellpadding="0" cellspacing="0" border="0" width="100%" >
	<tr><td valign="top" class="<?php echo $this->theme['title']; ?>" >
		<?php echo $this->config['title']; ?>
	</td>
	</tr>
	<tr><td height="23"></td></tr>
	<?php if ($this->config['cur_location'] == 1) {?>
	<tr><td height="0"></td></tr>
	<tr><td class="curloc">
		<?php echo JText::_('JS_CUR_LOC'); ?> : <?php echo JText::_('JS_JOB_ALERT_INFO'); ?>
	</td></tr>
	<?php } ?>
	<tr><td>
		<?php
		if (sizeof($this->jobseekerlinks) != 0){
			echo '<div id="toplinks"><ul>';
			foreach($this->jobseekerlinks as $lnk)	{ ?>
					<span <?php if($lnk[2] == 1)echo 'class="first"'; elseif($lnk[2] == -1)echo 'class="last"';  ?>>
					<a href="<?php echo $lnk[0]; ?>"> <?php echo $lnk[1]; ?></a>
				</span>
			<?php }
			echo '<ul></div>';
		}
		?>
	</td></tr>
	<tr><td height="3"></td></tr>

	<tr><td class="<?php echo $this->theme['heading']; ?>" align="center">
		<?php echo JText::_('JS_JOB_ALERT_INFO'); ?>
	</td></tr>

	<tr><td height="10"></td></tr>
</table>

<?php
if(isset($this->userrole))if ($this->userrole->rolefor == 2) { // job seeker
	$printform = 1;
	if ((isset($this->jobsetting)) &&($this->jobsetting->id != 0)) { // not new form
		if ($this->jobsetting->status == 1) { // Employment Application is actve
			$printform = 1;
		}else if($this->jobsetting->status == 0){ // not allowed job posting
			$printform = 0;
			echo "<font color='red'><strong>" . JText::_('JS_JOBALERT_WATING_FOR_APPROVAL') . "</strong></font>";
		} else{ // not allowed job posting
			$printform = 0;
			echo "<font color='red'><strong>" . JText::_('JS_JOBALERT_REJECTED') . "</strong></font>";
		}
	}
}elseif ($this->userrole->rolefor != 1) { // not employer
    if($this->config['overwrite_jobalert_settings'] == 1) $printform = 1;

}else{ // not allowed job posting
	$printform = 0;
	echo "<font color='red'><strong>" . JText::_('EA_YOU_ARE_NOT_ALLOWED_TO_VIEW') . "</strong></font>";
	//Update by Vireak on 09/08/2012
	//Add frame to this warning and some styling
	//---------------------
	echo '<div class="box-list"><div class="head-title"><h2>Oop!</h2></div>';
	echo '<span class="wr_info"><p>'.JText::_('JS_YOU_ARE_NOT_ALLOWED_TO_VIEW').'</p>';
	echo '<p>This page is reserved for the authorized candidates only. </p></span>';
	echo '</div>';
	//---------------------
}
if ($printform == 1) {
    if ($this->cansetjobalert == 1) $cansetjobalert = 1;
    
}
if ($printform == 1) {
if ($cansetjobalert == 1) { // add new resume, in edit case always 1

?>
<form action="index.php" method="post" name="adminForm" id="adminForm" class="form-validate" enctype="multipart/form-data"  onSubmit="return myValidate(this);">
    <table cellpadding="5" cellspacing="0" border="0" width="100%" class="adminform">
		<?php
		$i = 0; ?>
					
					  <tr>
						<td colspan="2" align="right">
						<?php if(isset($this->jobsetting->id)) {?>
							<a href='index.php?option=com_wrecruit&c=wrecruit&view=jobseeker&layout=jobalertunsubscribe&email=<?php echo $this->jobsetting->contactemail ; ?>' ><?php echo JText::_( 'JS_UNSUB_JOB_ALERT' ); ?></a>
						<?php }else { ?>							
							<a href='index.php?option=com_wrecruit&c=wrecruit&view=jobseeker&layout=jobalertunsubscribe' ><?php echo JText::_( 'JS_UNSUB_JOB_ALERT' ); ?></a>
						<?php } ?>							
						</td>
					</tr>
					
				      <tr>
				        <td valign="top" align="right"><label id="jobcategorymsg" for="categoryid"><?php echo JText::_('JS_CATEGORIES'); ?></label>&nbsp;<font color="red">*</font></td>
				        <td><?php echo $this->lists['jobcategory'];?></td>
				      </tr>
                                      <tr  >
                                        <td valign="top" align="right"><label id="subcategoryidmsg" for="subcategoryid"><?php echo JText::_('JS_SUB_CATEGORY'); ?></label></td>
                                        <td id="fj_subcategory"><?php echo $this->lists['subcategory'];?></td>
                                      </tr>
				      <tr>
                                          <td valign="top" align="right"><label id="contactemailmsg" for="contactemail"><?php echo JText::_('JS_CONTACTEMAIL');?></label>&nbsp;<font color="red">*</font></td>
				        <td><input class="inputbox required validate-email" type="text" name="contactemail" id="contactemail" size="40" maxlength="100" value="<?php if(isset($this->jobsetting)) echo $this->jobsetting->contactemail; ?>" />
				        </td>
				      </tr>
				      <tr>
				        <td align="right"><label id="countrymsg" for="country"><?php echo JText::_('JS_COUNTRY'); ?></label>&nbsp;<font color="red">*</font></td>
				        <td id="jobalert_country">
						      <?php echo $this->lists['country']; ?>
				        </td>
				      </tr>
				      <tr>
				        <td align="right"><label id="statemsg" for="state"><?php echo JText::_('JS_STATE'); ?></label></td>
				        <td id="jobalert_state">
						<?php
							if ((isset($this->lists['state'])) && ($this->lists['state']!='')){
								echo $this->lists['state']; 
							} else{ ?>
								<input class="inputbox" type="text" name="state" size="40" maxlength="100" value="<?php if(isset($this->jobsetting)) echo $this->jobsetting->state; ?>" />
							<?php } ?>
						</td>
				      </tr>
				      <tr>
				        <td align="right"><label id="countymsg" for="county"><?php echo JText::_('JS_COUNTY'); ?></label></td>
				        <td id="jobalert_county"><?php
							if ((isset($this->lists['county'])) && ($this->lists['county']!='')){
								echo $this->lists['county']; 
							} else{ ?>
								<input class="inputbox" type="text" name="county" size="40" maxlength="100" value="<?php if(isset($this->jobsetting)) echo $this->jobsetting->county; ?>" />
							<?php } ?>
				        </td>
				      </tr>
				      <tr>
				        <td align="right"><label id="citymsg" for="city"><?php echo JText::_('JS_CITY'); ?></label></td>
				        <td id="jobalert_city"><?php
							if((isset($this->lists['city'])) && ($this->lists['city']!='')){
								echo $this->lists['city']; 
							} else{ ?>
								<input class="inputbox" type="text" name="city" size="40" maxlength="100" value="<?php if(isset($this->jobsetting)) echo $this->jobsetting->city; ?>" />
							<?php } ?>
				        </td>
				      </tr>
				      <tr>
				        <td align="right"><label id="zipcodemsg" for="zipcode"><?php echo JText::_('JS_ZIPCODE'); ?></label></td>
				        <td><input class="inputbox" type="text" name="zipcode" size="40" maxlength="100" value="<?php if(isset($this->jobsetting)) echo $this->jobsetting->zipcode; ?>" />
				        </td>
				      </tr>
        <td colspan="2" height="10"></td>
      <tr>
	<tr>
		<td colspan="2" align="center">
		<input class="button" type="submit" name="submit_app" value="<?php echo JText::_('JS_SAVE'); ?>" />
		</td>
	</tr>
    </table>


	<?php 
				if(isset($this->jobsetting)) {
					if (($this->jobsetting->created=='0000-00-00 00:00:00') || ($this->jobsetting->created==''))
						$curdate = date('Y-m-d H:i:s');
					else  
						$curdate = $this->jobsetting->created;
				}else
					$curdate = date('Y-m-d H:i:s');
				
			?>
			<input type="hidden" name="created" value="<?php echo $curdate; ?>" />
			<input type="hidden" name="uid" value="<?php echo $this->uid; ?>" />
			<input type="hidden" name="id" value="<?php echo $this->jobsetting->id; ?>" />
			<input type="hidden" name="option" value="<?php echo $this->option; ?>" />
			<input type="hidden" name="task" value="savejobalertsetting" />
			<input type="hidden" name="check" value="" />
            <input type="hidden" name="Itemid" id="Itemid" value="<?php echo $this->Itemid; ?>" />
		
		  </form>
<script language=Javascript>
function deleteJobAlert(){
alert('1');
	document.adminForm.action = 'index.php?option=com_wrecruit&c=wrecruit&task=deleteJobAlertSetting';
alert('2');
            //document.getElementById('action').value=actionvalue;
            document.forms["adminForm"].submit();
// document.adminForm.submit(document.adminForm.action);
alert('3');
 }
function dochange(src, val){
	var pagesrc = 'jobalert_'+src;
	document.getElementById(pagesrc).innerHTML="Loading ...";
	var xhr; 
	try {  xhr = new ActiveXObject('Msxml2.XMLHTTP');   }
	catch (e) 
	{
		try {   xhr = new ActiveXObject('Microsoft.XMLHTTP');    }
		catch (e2) 
		{
		  try {  xhr = new XMLHttpRequest();     }
		  catch (e3) {  xhr = false;   }
		}
	 }

	xhr.onreadystatechange = function(){
      if(xhr.readyState == 4 && xhr.status == 200){
		
        	document.getElementById(pagesrc).innerHTML=xhr.responseText; //retuen value

			if(src=='state'){
				countyhtml = "<input class='inputbox' type='text' name='county' size='40' maxlength='100'  />";
				cityhtml = "<input class='inputbox' type='text' name='city' size='40' maxlength='100'  />";
				document.getElementById('jobalert_county').innerHTML=countyhtml; //retuen value
				document.getElementById('jobalert_city').innerHTML=cityhtml; //retuen value
			}else if(src=='county'){
				cityhtml = "<input class='inputbox' type='text' name='city' size='40' maxlength='100'  />";
				document.getElementById('jobalert_city').innerHTML=cityhtml; //retuen value
			}
      }
    }
 
	xhr.open("GET","index.php?option=com_wrecruit&task=listaddressdata&data="+src+"&val="+val,true);
	xhr.send(null);
 }
function fj_getsubcategories(src, val){
	var xhr;
	try {  xhr = new ActiveXObject('Msxml2.XMLHTTP');   }
	catch (e){
		try {   xhr = new ActiveXObject('Microsoft.XMLHTTP');    }
		catch (e2) {
		  try {  xhr = new XMLHttpRequest();     }
		  catch (e3) {  xhr = false;   }
		}
	 }

	xhr.onreadystatechange = function(){
            if(xhr.readyState == 4 && xhr.status == 200){
        	document.getElementById(src).innerHTML=xhr.responseText; //retuen value
            }
        }

	xhr.open("GET","index.php?option=com_wrecruit&task=listsubcategories&val="+val,true);
	xhr.send(null);
}

</script>
			  

		
<?php 
} else{ // not allowed job posting
echo JText::_('JS_YOU_ARE_NOT_ALLOWED_TO_VIEW');
}
} else{ // not allowed job posting
echo JText::_('JS_YOU_ARE_NOT_ALLOWED_TO_VIEW');

}
}//ol
?>
<div width="100%">
<?php include_once('components/com_wrecruit/views/fr_jscr.php'); ?>
</div>

